package com.wythe.mall.adapter;

import android.content.Context;
import android.support.v7.widget.AppCompatTextView;
import android.support.v7.widget.LinearLayoutCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.wythe.mall.R;
import com.wythe.mall.model.OrderBean;

import java.util.ArrayList;
import java.util.List;

public class OrderListAdapter extends RecyclerView.Adapter<OrderListAdapter.ViewHolder> {

    private final List<OrderBean> arrayList;
    private List<OrderBean.ItemVoBean> mItemLists;
    private Context mContext;
    private OnItemClickListener onItemClickListener;

    public OrderListAdapter(Context context, List<OrderBean> arrayList) {
        mContext = context;
        if (mItemLists == null) {
            mItemLists = new ArrayList<>();
        }
        this.arrayList = arrayList;
        this.onItemClickListener = null;
    }

    @Override
    public int getItemCount() {

        return arrayList.size();

    }

    @Override
    public void onBindViewHolder(final ViewHolder holder, int position) {

        final int positionInt = position;
//        final OrderBean bean = arrayList.get(position);
        StoreOrderListAdapter storeOrderListAdapter = new StoreOrderListAdapter(mContext,null);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        holder.mainRecyclerView.setLayoutManager(linearLayoutManager);//设置布局管理器
        holder.mainRecyclerView.setAdapter(storeOrderListAdapter);
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup group, int viewType) {
        View view = LayoutInflater.from(group.getContext()).inflate(R.layout.item_list_order, group, false);
        return new ViewHolder(view);
    }

    public void setOnItemClickListener(OnItemClickListener listener) {

        this.onItemClickListener = listener;

    }

    public interface OnItemClickListener {
        void onClick(int position, OrderBean bean);
    }

    class ViewHolder extends RecyclerView.ViewHolder {

        private LinearLayoutCompat mainLinearLayout;
        private RecyclerView mainRecyclerView;

        private ViewHolder(View view) {
            super(view);
            mainLinearLayout = (LinearLayoutCompat) view.findViewById(R.id.mainLinearLayout);
            mainRecyclerView = (RecyclerView) view.findViewById(R.id.mainRecyclerView);
        }

    }

}
